package com.xiyu.service.controller.admin.elder;
import com.xiyu.service.vo.elder.checkIn.CheckInUpdateStatusInput;
import com.xiyu.service.vo.elder.checkIn.CheckInGetOutput;
import com.xiyu.service.vo.elder.checkIn.CheckInUpdateInput;
import com.xiyu.service.vo.elder.checkIn.CheckInCreateInput;
import com.xiyu.service.vo.elder.checkIn.CheckInQueryOutput;
import com.xiyu.service.vo.elder.checkIn.CheckInQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.elder.CheckInService;

@Tag(name = "入住登记")
@RestController
@RequestMapping("/elder/check-in")
@Validated
public class CheckInController {

    @Resource
    private CheckInService checkInService;

    @GetMapping("/query")
    @Operation(summary = "分页查询入住登记")
    @PreAuthorize("@ss.hasPermission('elder:checkIn:query')")
    public CommonResult<PageResult<CheckInQueryOutput>> query(@Valid CheckInQueryInput inputVO) {
        return success(checkInService.query(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增入住登记")
    @PreAuthorize("@ss.hasPermission('elder:checkIn:create')")
    public CommonResult<Long> create(@Valid @RequestBody CheckInCreateInput inputVO) {
        return success(checkInService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新入住登记")
    @PreAuthorize("@ss.hasPermission('elder:checkIn:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody CheckInUpdateInput inputVO) {
        return success(checkInService.update(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个入住登记")
    @Parameter(name = "id", description = "入住登记ID", example = "")
    public CommonResult<CheckInGetOutput> get(@RequestParam("id") Long id) {
        return success(checkInService.get(id));
    }

    @PutMapping("/update-status")
    @Operation(summary = "更新入住登记状态")
    public CommonResult<Boolean> updateStatus(@Valid @RequestBody CheckInUpdateStatusInput inputVO) {
        return success(checkInService.updateStatus(inputVO));
    }

}
